<%@ page import="com.ld.manageBook.service.UserService" %>
<%@ page import="com.ld.manageBook.service.impl.UserServiceImpl" %>
<%@ page import="com.ld.manageBook.bean.User" %><%--
  Created by IntelliJ IDEA.
  User: 刘邓
  Date: 2023-06-02
  Time: 10:42
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>添加用户结果</title>
</head>
<body>
<%!
  private UserService userService = new UserServiceImpl();
%>
<%
  String userName = request.getParameter("username");
  String password = request.getParameter("password");
  Integer status = Integer.parseInt(request.getParameter("status"));
  User user = new User();
  user.setUsername(userName);
  user.setPassword(password);
  user.setStatus(status);
  User userByName = userService.getUserByName(userName);
  if(userByName != null){
    out.println("该用户已经存在");
  }else {
    int i = userService.addUser(user);
    if (i == 1) {
      out.println("<h1>添加成功</h1>");
    } else {
      out.println("<h1>添加失败,请稍后重试</h1>");
    }
  }
  out.println("<a href='/home/manageUser.jsp'>返回用户管理页</a>");
%>
</body>
</html>
